package com.chuanyang.driverh.mainorder.adapter;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.responseresult.CarTeamMenmberData;
import com.chuanyang.driverh.utils.BitmapUtil;

import java.util.List;

public class CarTeamMenmberAdapter extends BaseAdapter {
    private Context context;



    public void setList(List<CarTeamMenmberData> list) {
        this.list = list;
        this.notifyDataSetChanged();
    }

    private List<CarTeamMenmberData> list;
    private ViewHolder holder;

    public CarTeamMenmberAdapter(Context context, List<CarTeamMenmberData> list) {
        this.context = context;
        this.list = list;
    }



    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null)
        {
            convertView= View.inflate(context, R.layout.order_item_carteammenber,null);
            holder = new ViewHolder();
            holder.ll_carteammenmber_div= (LinearLayout) convertView.findViewById(R.id.ll_carteammenmber_div);
            holder.tv_carteammenmber_name= (TextView) convertView.findViewById(R.id.tv_carteammenmber_name);
            holder.iv_carteammenmber_icon= (ImageView) convertView.findViewById(R.id.iv_carteammenmber_icon);
            holder.tv_carteammenmber_load= (TextView) convertView.findViewById(R.id.tv_carteammenmber_load);
            holder.tv_carteammenmber_cartype= (TextView) convertView.findViewById(R.id.tv_carteammenmber_cartype);
            holder.tv_carteammenmber_plantnumber= (TextView) convertView.findViewById(R.id.tv_carteammenmber_plantnumber);
            convertView.setTag(holder);
        }
        else {
            holder= (ViewHolder) convertView.getTag();
        }
        CarTeamMenmberData bean=list.get(position);
        BitmapUtil.showImgForNetPath(bean.getUserImage(),holder.iv_carteammenmber_icon);
//        YncApplication.getInstance().loadCircleImage(context, bean.getUserImage(), R.drawable.shengfeng, R.drawable.shengfeng,holder.iv_carteammenmber_icon);

        holder.tv_carteammenmber_name.setText(bean.getUsername());
        holder.tv_carteammenmber_load.setText(bean.getCapacity()+"");
        holder.tv_carteammenmber_cartype.setText(bean.getCarType());
        holder.tv_carteammenmber_plantnumber.setText(bean.getPlateNumber());

        return convertView;
    }

    private  class ViewHolder
    {
       LinearLayout ll_carteammenmber_div;
        TextView tv_carteammenmber_load;
        TextView tv_carteammenmber_name;
        TextView tv_carteammenmber_cartype;
        TextView tv_carteammenmber_plantnumber;
        ImageView iv_carteammenmber_icon;
    }
}
